package com.ellricky.baselib.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.andr.common.ui.dialog.BaseDialog;
import com.andr.common.ui.dialog.listener.OnMyAlertListener;
import com.ellricky.baselib.R;
import com.flyco.roundview.RoundTextView;

public class DelConfirmDialog extends BaseDialog {

    private String msg;

    public void setListener(OnMyAlertListener listener) {
        this.listener = listener;
    }

    private OnMyAlertListener listener;

    @Override
    public int getCustomLayoutId() {
        return R.layout.dialog_del_confirm;
    }

    public DelConfirmDialog(Context context) {
        super(context);
        setGravity(Gravity.CENTER);
        setCanceledOnTouchOutside(true);
        setCancelable(true);
    }


    @Override
    public void initWidgets() {

        TextView tvMsg = findViewById(R.id.tv_msg);

        RoundTextView tvCancel = findViewById(R.id.btnCancel);
        tvCancel.setOnClickListener(this);

        RoundTextView tvConfirm = findViewById(R.id.btnSubmit);
        tvConfirm.setOnClickListener(this);

        if (tvMsg != null) {
            tvMsg.setText(msg);
        }

    }


    @Override
    public void onClickView(View v) {
        if (listener == null) return;
        if (v.getId() == R.id.btnCancel)
            dismiss();
        else if (v.getId() == R.id.btnSubmit)
            listener.onSure(this);
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

}
